#ifndef _BASICEFFECT_H_
#define _BASICEFFECT_H_

#include <windows.h>
#include <xnamath.h>
#include <d3d11.h>
#include <d3dx11async.h>
#include <fstream>
#include "Texture.h"
#include "PointsLightsManager.h"
#include <Effect11/d3dx11effect.h>


struct DirectionalLight
{
	XMFLOAT4 Ambient;
	XMFLOAT3 Direction;
	float pad;
};

class BasicEffect
{
public:

	void Initialize();
	void Uninit();

	void SetEyesPosition(const XMFLOAT3 &pEyesPosition);
	void SetTransformsMatrices(const XMFLOAT4X4&,const XMFLOAT4X4&,const XMFLOAT4X4&);
	void SetTexture(Texture *pTexture);
	void SetShadowTexture(ID3D11ShaderResourceView* pTexture);
	void SetLightDirLightEnable();
	void SetLightDirLightDisable();
	void SetPointLightList(PointLight* pListPointsLights, int pPointLightCount);

	PointsLightsManager* GetPointsLightsManager();

	void Render(int indexCount);
	void RenderBillboard(int pIndexCount);

	ID3D11InputLayout* GetBillboardInputLayout();
protected:
	void InitInputLayout();
	void InitInputLayoutBillboard();
	void InitBlendState();
	void InitSamplerState();

	ID3D11Device* mDevice;
	ID3D11DeviceContext* mDeviceContext;
	Texture *mTexture;
	ID3D11ShaderResourceView *mShadowTexture;
	ID3D11ShaderResourceView* mDepthTexture;
	ID3DX11Effect* mEffect;
	ID3DX11EffectTechnique* mTechnique;
	ID3DX11EffectTechnique* mTechniqueBillboard;
	ID3D11InputLayout* mInputLayout;
	ID3D11InputLayout* mBillboardInputLayout;
	ID3D11BlendState* mBlendState; 

	ID3DX11EffectMatrixVariable* mFxMatrixWorld;
	ID3DX11EffectMatrixVariable* mFxMatrixView;
	ID3DX11EffectMatrixVariable* mFxMatrixProjection;
	ID3DX11EffectMatrixVariable* mFxShadowMatrixView;
	ID3DX11EffectMatrixVariable* mFxShadowMatrixProjection;
	ID3DX11EffectVariable* mFxEyesPosition;
	ID3DX11EffectConstantBuffer* mFxLightBufferCB;
	ID3DX11EffectVariable* mFxMaterial;
	ID3DX11EffectVariable* mFxDirectionalLight;
	ID3DX11EffectVariable* mFxEnableDirLightDirLight;
	ID3DX11EffectVariable* mFxListPointsLights;
	ID3DX11EffectVariable* mFxPointLightCount;

	ID3D11SamplerState* mSampleState;
	

	PointsLightsManager* mPointsLightsManager;
	PointsLightsManager* mPointsLightsDynamicsManager;
};

#endif